﻿using System;
using System.Collections.Generic;
using CiStatus.CiStatusAddIn.Logic;
using CiStatus.CiStatusAddIn.Logic.Parameters;
using CiStatus.CiStatusAddIn.Logic.PluginInterfaces;
using CiStatus.CiStatusAddIn.Logic.Status;
using CiStatus.CiStatusAddIn.ViewModels;

namespace CiStatus.CiStatusAddIn.SampleData
{
    public static class Sample
    {
		private static readonly IDictionary<string, ICiPollerParameter> dummy1 = new Dictionary<string, ICiPollerParameter>
		{
		                                                {"Project", new SimpleKeyValueStringParameter("MyProject")},
														{"Server", new SimpleKeyValueStringParameter("MyServer")},
														{"Link", new SimpleKeyValueStringParameter("http://myserver")}
		};

		private static readonly IDictionary<string, ICiPollerParameter> dummy2 = new Dictionary<string, ICiPollerParameter>
		{
		                                                {"Project", new SimpleKeyValueStringParameter("1SampleProject")},
														{"Server", new SimpleKeyValueStringParameter("ServerName")},
														{"Link", new SimpleKeyValueStringParameter("http://myserver")}
		};
		private static readonly IDictionary<string, ICiPollerParameter> dummy3 = new Dictionary<string, ICiPollerParameter>
		{
		                                                {"Project", new SimpleKeyValueStringParameter("2SampleProject")},
														{"Server", new SimpleKeyValueStringParameter("ServerName")},
														{"Link", new SimpleKeyValueStringParameter("http://myserver")}
		};

        public static IDictionary<string, ICiPollerParameter> CreateSettings
        {
            get { return dummy1; }
        }

        public static CiStatusViewModel CreateCiStatusViewModelSample
        {
            get
            {
                return new CiStatusViewModel(new SamplePump());
            }
        }

        public static ProjectViewModel CreateProjectViewModelSample
        {
            get
            {
                return new ProjectViewModel(new Project(new SampleStatus(), dummy2));
            }
        }

        public static IStatus CreateStatus
        {
            get
            {
                return new SampleStatus().CurrentStatus;
            }
        }

        public static StatusDetails CreateDetails
        {
            get
            {
                var details = new StatusDetails
                {
                    Message = "Success",
                    Activity = "Sleeping",
                    BuildLabel = "233",
                    BuildStatus = "Running",
                    BuildTime = new DateTime(2010, 12, 13),
                    Details = "Going well here",
                    Progress = new Progress(45,19)
                };
                return details;
            }
        }

        public class SamplePump : IRefreshPump
        {
            public bool IsStarted
            {
                get { return true; }
            }

            public IEnumerable<IProject> ProjectCollection
            {
                get
                {
                    return new List<IProject>
                               {
                                   new Project(new SampleStatus(), dummy2),
                                   new Project(new SampleStatus(), dummy3)
                               };
                }
            }

            public void Start(ICallBack callBack)
            {}

            public void Stop()
            {}
        }

        public class SampleStatus : IRefreshCiStatus
        {
            public IStatus Refresh(ICallBack callBack)
            {
                var details = new StatusDetails {Message = "Offline"};
                var status = new StatusOffline(details);
                return status;
            }

            public IStatus PreviousStatus
            {
                get
                {
                    var details = new StatusDetails { Message = "Offline" };
                    var status = new StatusOffline(details);
                    return status;
                }
            }

            public IStatus CurrentStatus
            {
                get
                {
                    var details = new StatusDetails
                                      {
                                          Message = "Success",
                                          Activity = "Sleeping",
                                          BuildLabel = "233",
                                          BuildStatus = "Running",
                                          BuildTime = new DateTime(2010,12,13),
                                          Details = "Giong well here",
                                          Progress = new Progress(4566,1233)
                                      };
                    return new StatusSuccess(details);
                }
            }
        }
    }
}
